package com.qf.service.impl;

import com.qf.entity.TChannel;
import com.qf.events.ChannelEvent;
import com.qf.mapper.ChannelMapper;
import com.qf.service.ChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/*
杨威
2021/11/6
14:27
*/
@Service
@Transactional
public class ChannelServiceImpl implements ChannelService {
    @Autowired
    ChannelMapper channelMapper;
    @Autowired
    ApplicationContext context;
    @Override
    public int add(TChannel tChannel) {
        int i = channelMapper.addChannel(tChannel);
        context.publishEvent(ChannelEvent.class);
        return i;
    }

    @Override
    public int remove(Integer id) {
        int i = channelMapper.deleteChannel(id);
        context.publishEvent(ChannelEvent.class);
        return i;
    }

    @Override
    public int modify(TChannel tChannel) {
        int i = channelMapper.updateChannel(tChannel);
        context.publishEvent(ChannelEvent.class);
        return i;
    }

    //查询在缓存里 不在service里查询了
    @Override
    public List<TChannel> findAll() {
        return null;
    }

    @Override
    public TChannel findById(Integer id) {
        return null;
    }
}
